//启动指令npx ts-node src/index.ts
import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import dashboardRoutes from './routes/dashboard';
import enterpriseRoutes from './routes/enterprise';
import totalRoutes from './routes/total';
import risingRoutes from './routes/rising';
import riskRoutes from './routes/risk';
import { connectDB } from './db/connection';

connectDB(); // 连接数据库

const app = express();
const PORT = 5000;

// 中间件
app.use(cors());
app.use(bodyParser.json());

// 路由
app.use('/api/dashboard', dashboardRoutes);
app.use('/api/enterprise', enterpriseRoutes);
app.use('/api/total', totalRoutes);
app.use('/api/rising', risingRoutes);
app.use('/api/risk', riskRoutes);

// 启动服务器
app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});